package com.lipl.config;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
 * @author ycy
 */
@Slf4j
@Configuration
public class TaskExecutorConfiguration {

    @Bean("mbsTaskExecutor")
    public TaskExecutor ThreadPoolTaskExecutor() {
        log.debug("start thread pool task executor");
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(10);
        executor.setQueueCapacity(1000);
        executor.setThreadNamePrefix("task-executor-thread");
        executor.initialize();
        log.debug("thread pool task executor initialized");
        return executor;
    }
}
